//
//  YDVistorViewController.swift
//  YDWeibo01
//
//  Created by suibian on 16/8/9.
//  Copyright © 2016年 iitcast. All rights reserved.
//

import UIKit

class YDVistorViewController: UIViewController {

    
//    判断用户是否登录     //默认为没登录
    var isLogin:Bool = YDUserAccountViewModel.sharedTools.isLogin
//    访客视图View
    var vistorView: YDVistorView?
    
    
    override func loadView() {
        if isLogin{
        view = tableView 
        
        }else{
        
        
            setupVistorView()
           
        }
    }
    
//    设置访客视图
    func setupVistorView(){
        setupNav() 
        
//        vistorView!.backgroundColor = randomColor()
        vistorView = YDVistorView()
        vistorView?.closure = {
        
        self.loginAction()
        
        }
        view = vistorView
        

    
    
    }
    
//    设置导航
    
    func setupNav(){
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "loginAction")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "loginAction")

    
    }
    
    func loginAction(){
    
    print("登录注册按钮点击")
    
        let oauthVc = YDOAuthViewController()
//        有导航栏所以要用nav
        presentViewController(UINavigationController(rootViewController: oauthVc), animated: true, completion: nil)
    }
    override func viewDidLoad() {
        super.viewDidLoad()

    }
    
//  懒加载控件
    lazy var tableView:UITableView = UITableView()
    
}
